Skip to content

Conversation

TomasHofman
Copy link
Contributor

@TomasHofman TomasHofman commented Oct 2, 2025

This improves the path matching logic in resteasy-reactive server. It fixes the case when there are overlapping path templates registered, such as:

  • /path/foo/{param}
  • /path/foo/bar/{param}

and the incoming request has path /path/foo/bar_something. The expectation is that this path should be matched by the first template. The current behavior however is that server returns 404.

@TomasHofman TomasHofman changed the title Issue 50330 Fix handling of overlapping paths in resteasy-reactive server Oct 2, 2025
@quarkus-bot quarkus-bot bot added area/agroal area/amazon-lambda area/arc Issue related to ARC (dependency injection) area/cache area/cli Related to quarkus cli (not maven/gradle/etc.) area/codestarts area/config area/context-propagation area/core area/dependencies Pull requests that update a dependency file area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins area/docstyle issues related for manual docstyle review area/documentation area/elasticsearch area/fault-tolerance area/flyway area/funqy area/google-cloud-functions area/gradle Gradle area/graphics area/graphql area/grpc gRPC area/health area/hibernate-validator Hibernate Validator area/hibernate-orm Hibernate ORM area/hibernate-search Hibernate Search area/hibernate-reactive Hibernate Reactive area/infinispan Infinispan area/jackson Issues related to Jackson (JSON library) labels Oct 2, 2025
@geoand geoand removed area/google-cloud-functions area/codestarts area/cli Related to quarkus cli (not maven/gradle/etc.) area/jbang Issues related to when using jbang.dev with Quarkus area/websockets area/mailer area/agroal area/reactive-sql-clients area/reactive-streams-operators area/picocli area/jackson Issues related to Jackson (JSON library) area/keycloak area/graphics area/context-propagation area/stork area/lra area/docstyle issues related for manual docstyle review area/netty area/jdbc Issues related to the JDBC extensions area/qute The template engine labels Oct 2, 2025
@geoand
Copy link
Contributor

geoand commented Oct 3, 2025

Thanks @TomasHofman!

Did this pass CI on your fork?

@TomasHofman
Copy link
Contributor Author

Hi @geoand , I was locally running tests in following two modules:

  • independent-projects/resteasy-reactive/server/
  • extensions/resteasy-reactive/rest/

and those did pass. I was hoping to get more coverage here on the PR. Now as I reread the contributors file I will get GH actions working on my fork and let you know 👍 (it's been few years since I last contributed here).

@TomasHofman
Copy link
Contributor Author

@geoand actually the CI on my fork had run, and looks green (if you can access here? https://github.com/TomasHofman/quarkus/actions/runs/18191107425)

.body(equalTo("Foo bar_value"));
}

// TODO: remove this test before commit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this need to be removed :)

@geoand
Copy link
Contributor

geoand commented Oct 3, 2025

Cool! In that case, feel free to take it out of draft when you are done

@TomasHofman
Copy link
Contributor Author

@geoand sure, I will take bit more time, I'm looking at one more touch point.

@geoand
Copy link
Contributor

geoand commented Oct 3, 2025

Thanks! No rush

This solves further problems in case when the paths are spread over
multiple resource classes. Improves earlier PR:

quarkusio#47386
}

return -1;
return 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have added a comment here... This last return statement represents a case when the current match is not found in the list of new initial matches. In which case we want to search those new matches from index 0. The -1 would mean that no more matches will be tested.

@TomasHofman
Copy link
Contributor Author

@geoand I think I made some progress - I added a second commit and waiting for CI results.

The second commit tries to improve previous PR #47386, which kinda got in my way. It handles similar case to the current issue, but the overlapping paths are spread over multiple resource classes. (The test case added in that PR passes, but can be easily broken just by adding one more segment to the resource paths. So the fix is not 100% correct in that sense.)

I was originally hoping to replace that PR by something simpler, as I thought it's little too complex and not following the previous design, but I was not able to figure out simpler solution yet.

Looking from the outsider point of view, it looks to me that the code as written originally by Stuart did not really expect people to use all these overlapping paths across resource classes and methods. It just picked an "initial match" of seemingly best matching resource class (if I understand correctly what the "initial match" is about), and then picked seemingly best matching method path and tried to evaluate that, without doing any backtracking in case the pick was not eventually working. Now all these fixes are making it quite bit more complex. Where I'm heading we could say to developers "don't use the overlapping paths" :) and keep things simpler, or keep increasing the complexity to accommodate devs. And maybe one day redesign when it gets too bad...

Anyway, sorry for rumbling. I will wait for the CI results and signal here when they are available. Then leave it to your judgment if to include both commits or maybe just the first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JAX-RS returns 404 incorrectly for route with path parameter containing prefix that matches segment from another route
2 participants